<?php

namespace app\index\controller;

use think\Controller;
use think\Env;
use app\facade\Test;
use app\facade\TestBind;

class Index extends Controller
{

    protected $user;

    //构造函数
    public function __construct($user = 10)
    {
        $this->user = $user;
    }

    /**
     * 路由注解
     * @return string
     * @route('app/index','get')
     */
    public function index()
    {
dump($_SERVER['DOCUMENT_ROOT']);
dump(strrchr($_SERVER['DOCUMENT_ROOT'], "/"));
dump(substr(strrchr($_SERVER['DOCUMENT_ROOT'], "/"), 1));
        //   return 'hello ThinkPHP5.1';

        // 视图
        return $this->fetch();
    }

    /**
     * 当前根目录获取视图
     */
    public function menu()
    {

        // 视图
        return $this->fetch('/menu');
    }

    /**
     * @param string $name
     */
    public function hello($name = 'ThinkPHP5')
    {
        //实例化访问
        //$test = new Test();
        // echo $test->hello("thinkphp");
        //门面（静态访问）
        echo Test::hello("thinkphp");
        // return 'hello,' . $name;
    }

    public function hello_bind($name = 'ThinkPHP5')
    {
        //门面（静态访问）
        // Facade::bind('app\facade\TestBind','app\common\TestBind');
        echo TestBind::hello_bind("thinkphp");
    }

    /**
     * 路由
     */
    public function route()
    {
        echo Env::get('route_path');
    }

    public function app_cache()
    {
        dump(app('cache'));
        echo "<hr/>";
        dump(app()->config->get("app_name"));
    }
}
